<?php
if(!isset($phprpg->input['plugin'])){
	$page->header('Settings');
	$getPlugins = $db->select("plugins","*");
	$table = new table;

	$table->cell('<a href="index.php?module=config&page=settings&plugin=0">Core Settings</a>');
	$table->build_row();

	$table->output();
	$page->footer();
}else{
	if($phprpg->input['plugin'] == 0){
		$getSettings = $db->select("settings","*","plugin=0");
	}else{
		$getPlugin = $db->select("plugins","*","id=".intval($phprpg->input['plugin']));
		if($db->recordcount($getPlugin) == 1){
			$getSettings = $db->select("settings","*","plugin=".intval($phprpg->input['plugin']));
		}else{
			header("location: index.php?module=config&page=settings");
			exit;
		}
		$page->header('Settings');
		$form = new form;
		$table = new table;

		while($s = $db->fetchrow($query)){
			if($s['type'] == "text"){
				$field = $form->generate_text($s['name'],$s['value']);
			}elseif($s['type'] == "yesno"){
				$field = $form->generate_yesno($s['name'],$s['value']);
			}elseif($s['type'] == "textarea"){
				$field = $form->generate_textarea($s['name'],$s['value']);
			}
			$table->cell('<strong>'.$s['title'].'</strong>',array('width' => '25%'));
			$table->cell($field);
			$table->build_row();
		}

		$table->output();
		$form->end();
		$page->footer();
	}
}
?>